<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<link href="./css/modern.css" rel="stylesheet"> 
<link href="./css/style-prof-portal.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<script>
function ViewValidation()
{
	var radios = document.getElementsByName('radio');
	for(var i =0; i< radios.length; i++)
	{
		if(radios[i].checked){
			var confirmBox=confirm("Are you sure you want to remove this student from the group? Make sure to there are no TA duties added before proceeding.");
			if (confirmBox==true)
			{
			  	return true;
			}
			else
			{
			  	return false;
			}
		}
	}
	
	alert("Please Select a Student to Remove!");
	return false;
}
</script>

<%
	String firstname = (String) request.getAttribute("firstname");
	String lastname = (String) request.getAttribute("lastname");
	String courseNumber = (String) request.getAttribute("courseNumber");
	String sectionNumber = (String) request.getAttribute("sectionNumber");
	String message = (String) request.getAttribute("Message");
%>
<body>
<div id="container">
	<div id="header"><br>
		<h1 id="main-title"><b><font color = "000000">EECE Student Group Assessments</b></font></h1>
		<h2>Welcome to <%=courseNumber%> Section <%=sectionNumber%> Group List <%=firstname%> <%=lastname%>! 
			<a href="index.html">
			<p align="right"><font size = "5">Logout</font></p>
			</a>
		</h2>		
	</div>
	<%if(message != null){ %>
		<%if(message.equals("Failed")) {%>
		<div class="error(info, warning)-bar" id="messageDialog" align="center"><br>
			<p><b><font color = "black">Delete Failed! Make sure there are no TA Duties assigned to Students</font></b></p>
		</div>
		<%} else if(message.equals("Success")){%>
		     		<div class="error(info, warning)-bar" id="successmessageDialog" align="center"><br>
			<p><b><font color = "black">A Student has been Removed from a Group!</font></b></p>
					</div>
    	<%} else if(message.equals("Success Add")){%>
		     		<div class="error(info, warning)-bar" id="successmessageDialog" align="center"><br>
			<p><b><font color = "black">Students have been placed added to a group!</font></b></p>
					</div>
    	<%}%>
    <%}%>
    <div id="body" class="page-region-content tiles">
            <form id=form method="post" action="ProfBackCoursePortalServlet" >
             	<a href = "javascript:;" onclick="document.getElementById('form').submit();" class="back-button big page-back">
             		<input type = "hidden" name = "firstname" value = <%=firstname%>>
					<input type = "hidden" name = "lastname" value = <%=lastname%>>	
					<input type = "hidden" name = "courseNumber" value = "<%=courseNumber%>">
					<input type = "hidden" name = "sectionNumber" value = <%=sectionNumber%>>	
             	</a>
            </form>
        	<div id="innerBody" class="page-region-content tiles">
		<h1><%=courseNumber%> Class/TA List Section <%=sectionNumber%></h1><br>
		<form id="viewGroup" action="ProfEditGroupServlet" method="get">
					<input type = "hidden" name = "firstname" value = <%=firstname%>>
					<input type = "hidden" name = "lastname" value = <%=lastname%>>	
					<input type = "hidden" name = "courseNumber" value = "<%=courseNumber%>">
					<input type = "hidden" name = "sectionNumber" value = <%=sectionNumber%>>	
<table cellspacing="0" cellpadding="0" border="0" width="325" class="striped" border=1>
  <tr>
    <td>
       <table cellspacing="0" cellpadding="1" border="0" width="300"class="striped" border=1 >
         <tr>
            <th>Student Group List</th>
         </tr>
       </table>
    </td>
  </tr>
  <tr>
    <td>
       <div style="100%; height:500px; width: 1000px; overflow:auto;">
         <table class="fixed" cellspacing="0" cellpadding="1" border="0" width="300" class="striped" border=1>
           <tr>
           		<td><b></b></td>
          	    <td><b>Group Number</b></td>
				<td><b>Student ID</b></td>
				<td><b>First Name</b></td>
				<td><b>Last Name</b></td>
				<td><b>Program</b></td>
				<td><b>Year</b></td>
           </tr>
           <c:forEach items="${GroupsInfo}" var="Info">
           <tr>
           		<td><label class="radio" onclick=""> 
           		<input type="radio" name="radio" value="${Info.studentID}/${Info.groupNumber}" /></label>
           		</td>
           		<td><c:out value="${Info.groupNumber}" /></td>
				<td><c:out value="${Info.studentID}" /></td>
				<td><c:out value="${Info.firstName}" /></td>
				<td><c:out value="${Info.lastName}" /></td>
				<td><c:out value="${Info.program}" /></td>
				<td><c:out value="${Info.year}" /></td>
           </tr>
           </c:forEach>
         </table>  
       </div>
    </td>
  </tr>
</table>
<input type="submit" name = "button" value="Delete Student from Group" onclick ="return ViewValidation()"/>
</form>

<form id="AddGroup" action="ProfAddGroupManualServlet" method="get">
					<input type = "hidden" name = "firstname" value = <%=firstname%>>
					<input type = "hidden" name = "lastname" value = <%=lastname%>>	
					<input type = "hidden" name = "courseNumber" value = "<%=courseNumber%>">
					<input type = "hidden" name = "sectionNumber" value = <%=sectionNumber%>>
<%int i =0; %>	
<table cellspacing="0" cellpadding="0" border="0" width="325" class="striped" border=1>
  <tr>
    <td>
       <table cellspacing="0" cellpadding="1" border="0" width="300"class="striped" border=1 >
         <tr>
            <th>Students Not Added to a Group</th>
         </tr>
       </table>
    </td>
  </tr>
  <tr>
    <td>
       <div style="100%; height:300px; width: 1000px; overflow:auto;">
         <table class="fixed" cellspacing="0" cellpadding="1" border="0" width="300" class="striped" border=1>
           <tr>
				<td><b>Student ID</b></td>
				<td><b>First Name</b></td>
				<td><b>Last Name</b></td>
				<td><b>Program</b></td>
				<td><b>Year</b></td>
				<td><b>Specify Group Division</b></td>
				<td><b>Specify Group Number</b></td>
				<td><b>Specify Classroom</b></td>
           </tr>
           <c:forEach items="${unGroupedInfo}" var="Info">
           <tr>
				<td><c:out value="${Info.studentID}" /></td>
				<td><c:out value="${Info.firstName}" /></td>
				<td><c:out value="${Info.lastName}" /></td>
				<td><c:out value="${Info.program}" /></td>
				<td><c:out value="${Info.year}" /></td>
				<td><input type="text" name="division<%=i%>"/></td>
				<td><input type="text" name="groupNumber<%=i%>"/></td>
				<td><input type="text" name="classroom<%=i%>"/></td>
				<input type = "hidden" name = "studentID<%=i%>" value = "${Info.studentID}">
           </tr>
           <%i++;%>
           </c:forEach>
         </table>  
       </div>
    </td>
  </tr>
</table>
<input type = "hidden" name = "size" value = <%=i%>>
<input type="submit" name = "button" value="Add Students to Group(s)"/>
</form>


</div>
	</div>
	<div id="footer">
			&copy;UBC Electrical and Computer Engineering. Styled with <a
				href="http://metroui.org.ua">Metro UI CSS</a>
		</div>
</div>
</body>
</html>